// ==UserScript==
// @name         es6 Test
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&ch=&tn=02003390_43_hao_pg&bar=&wd=%E6%B2%B9%E7%8C%B4+es6&oq=%25E6%25B2%25B9%25E7%258C%25B4%2520ecmascript6&rsv_pq=b0d20d0f000ebc64&rsv_t=dfd8iZjy2QbeMktlVMcB0S42VpGOWydaLYZi3jfWjk8SQh5HaUFovoOQUETj54LHNJMecKT6pEyM&rqlang=cn&rsv_enter=1&rsv_dl=tb&inputT=2232
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    class Parent {
        //es6中定义构造函数
        constructor(name = 'com', age) {
            this.name = name;
            this.age = age;
        }

        say() { //这是一个类的方法，注意千万不要加上function
            return "我的名字叫" + this.name + "今年" + this.age + "岁了";
        }
    }


    class Child extends Parent {

    }

    //继承传递参数，将参数传递给父类
    class Child2 extends Parent {
        constructor(name = 'child') {
            super(name); //super一定放在构造函数的第一行
            this.type = 'child';
        }

        say(){
        	return "我不知道";
        }
    }

    let v_parent = new Parent('net', 88);
    console.info(v_parent);
    console.log(v_parent.say());
    let v_child = new Child("aaaa",66);
    console.log(v_child); //{name:"com"}
    console.log(v_child.say());
    let v_child2=new Child2();
    console.log(v_child2);
    console.log(v_child2.say());


})();